﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Management.Automation;
using System.Management.Automation.Host;
using System.Security;

namespace BGShell.PowerShell.Host
{
    internal sealed class RunspacePSHostUI : PSHostUserInterface
    {
        private readonly IRunspaceHostUI _owner;
        private readonly PSHostRawUserInterface _rawui;

        public RunspacePSHostUI(IRunspaceHostUI owner)
        {
            _owner = owner;
            _rawui = new RunspacePSHostRawUI(owner.RawUI);
        }

        public override Dictionary<String, PSObject> Prompt(String caption, String message, Collection<FieldDescription> descriptions)
        {
            return _owner.Prompt(caption, message, descriptions);
        }

        public override int PromptForChoice(String caption, String message, Collection<ChoiceDescription> choices, int defaultChoice)
        {
            return _owner.PromptForChoice(caption, message, choices, defaultChoice);
        }

        public override PSCredential PromptForCredential(String caption, String message, String userName, String targetName, PSCredentialTypes allowedCredentialTypes, PSCredentialUIOptions options)
        {
            return _owner.PromptForCredential(caption, message, userName, targetName, allowedCredentialTypes, options);
        }

        public override PSCredential PromptForCredential(String caption, String message, String userName, String targetName)
        {
            return _owner.PromptForCredential(caption, message, userName, targetName);
        }

        public override PSHostRawUserInterface RawUI
        {
            get { return _rawui; }
        }

        public override string ReadLine()
        {
            return _owner.ReadLine();
        }

        public override SecureString ReadLineAsSecureString()
        {
            return _owner.ReadLineAsSecureString();
        }

        public override void Write(ConsoleColor foregroundColor, ConsoleColor backgroundColor, String value)
        {
            _owner.Write(foregroundColor, backgroundColor, value);
        }

        public override void Write(String value)
        {
            _owner.Write(value);
        }

        public override void WriteDebugLine(String message)
        {
            _owner.WriteDebugLine(message);
        }

        public override void WriteErrorLine(String value)
        {
            _owner.WriteErrorLine(value);
        }

        public override void WriteLine(String value)
        {
            _owner.WriteLine(value);
        }

        public override void WriteProgress(long sourceId, ProgressRecord record)
        {
            _owner.WriteProgress(sourceId, record);
        }

        public override void WriteVerboseLine(String message)
        {
            _owner.WriteVerboseLine(message);
        }

        public override void WriteWarningLine(String message)
        {
            _owner.WriteWarningLine(message);
        }
    }
}
